import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:stock_helper/routers/app_pages.dart';
import 'package:stock_helper/data/datasource/local/database.dart';
import 'package:get/get.dart';
import 'data/datasource/local/database_manager.dart';


Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  // 初始化数据库
  final database = DatabaseManager.instance;
  runApp(MyApp(database: database));
  // 在适当的位置（如main.dart中）添加以下代码
}

class MyApp extends StatelessWidget {
  final AppDatabase database;

  const MyApp({super.key, required this.database});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return GetMaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Stock Helper',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        appBarTheme: const AppBarTheme(centerTitle: true),
      ),
      initialRoute: "/main",
      // onGenerateRoute: onGenerateRoute,
      //defaultTransition: Transition.rightToLeft,
      getPages: AppPages.getAllViews(),
      initialBinding: BindingsBuilder(() {
        Get.put(database);
      }),
    );
  }
}
